<?php
require('config.php');

        $user_id=$_REQUEST['user_id'];
		$sql="select * from `".$oto."_users` where `userId`='".$user_id."' and `userFlag`='1' LIMIT 1";
		$result=$db->query($sql);
		while($row=$result->fetch_assoc()){
			$user_info[]=$row;//将取得的所有数据赋值给person_info数组
		}
		$sql="select * from `".$oto."_youhui_user_link`,`".$oto."_youhui` where ".$oto."_youhui_user_link.user_id='{$user_id}' and u_is_effect='1' and ".$oto."_youhui_user_link.youhui_id=".$oto."_youhui.id";
		$result=$db->query($sql);
		while($row=$result->fetch_assoc()){
			$youhui[]=$row;//将取得的所有数据赋值给person_info数组
		}
		if(isset($youhui))
		{
			$sum=0;
			for($i=0;$i<count($youhui);$i++)
			{
				$shop_id=$youhui[$i]['supplier_id'];
				$sql="select shopName,shopImg,goodsCatId1 from `".$oto."_shops` where shopId='{$shop_id}'";
				$result=$db->query($sql);
				while($row=$result->fetch_assoc()){
					$shops[$i][]=$row;//将取得的所有数据赋值给person_info数组
				}
				if(isset($shops[$i]))
				{
					$youhui[$i]['shopName']=$shops[$i][0]['shopName'];
					$youhui[$i]['shopImg']=$shops[$i][0]['shopImg'];
					$youhui[$i]['goodsCatId']=$shops[$i][0]['goodsCatId1'];
				}
				else
				{
					$youhui[$i]['shopName']="";
					$youhui[$i]['shopImg']="";
					$youhui[$i]['goodsCatId']="0";
				}
				$max=$youhui[$i]['surplus'];
				for($j=0;$j<$max;$j++)
				{
					$data[$sum]=$youhui[$i];
					$sum++;
				}
			}
			$user_info[0]['youhui_num']=count($data);
		}
		else $user_info[0]['youhui_num']=0;
		echo json_encode($user_info);
?>